package com.guli.oss.controller;

import com.guli.oss.service.FileService;
import com.guli.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

//@CrossOrigin
@RestController
@RequestMapping("/oss/file")
public class FileController {

    @Autowired
    private FileService fileService;

    @PostMapping("/uploadImg")
    private R  uploadAvatar(MultipartFile file){      //前端传来的文件name一定要一样
        String uploadUrl =  fileService.uploadFile(file);
        return R.ok().message("文件上传成功").data("url", uploadUrl);
    }


}
